package com.jia.together.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jia.together.entity.Category;
import com.jia.together.service.CategoryService;
import com.jia.together.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/front/category")
//@CrossOrigin
public class CategoryFrontController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/list")
    public R list(){
        QueryWrapper<Category> wrapper = new QueryWrapper<>();
        wrapper.orderByAsc("sort");
        List<Category> list = categoryService.list(wrapper);
        return R.ok().data("data",list);
    }
}
